package pl.poznan.put.cs.idss.particlefilter.utils;

import java.util.Random;

import org.uncommons.maths.random.GaussianGenerator;

/**
 * 
 * @author Gosia
 *	generator gaussowski
 */
public class GaussianTool {

	private Random random = new Random();
	private GaussianGenerator gaussianGenerator;

	/**
	 * generuje liczbę na podstawie rozkładu gaussa i zadanego szumu
	 */
	public double getNextGaussian(double noise) {
		//random = new Random(System.currentTimeMillis());
		gaussianGenerator = new GaussianGenerator(0.0, noise, random);
		return gaussianGenerator.nextValue();
	}
	/**
	 * calculates the probability of x for 1-dim Gaussian with mean mu and var. sigma

	 */
	public double getGaussianProbability(double mu, double sigma, double x){
		return Math.exp(-(Math.pow((mu - x), 2)) / Math.pow(sigma,2)  / 2.0) / Math.sqrt(2.0 * Math.PI * Math.pow(sigma , 2));
	}
	
}
